
 class Array<T>{//T表示的是一个占位符，表示这是一个泛型类

  /*  public T[] array=(T[]) new Object[10];*/
     public Object[] array=new Object[10];

    public void setArray(int pos,T val){

        array[pos]=val;
    }

    public T getArray(int pos){

        return (T)array[pos];
    }

 }
public class Test {
    public static void main5(String[] args) {


    }

    public String username="ddsd";
    public String password="dddd";
public  void func(String username,String password ){

    if(this.username!=username){

        throw new RuntimeException("用户名异常！");

    }else if(this.password!=password){
        throw new RuntimeException("密码错误！");
    }
}

    public static void main2(String[] args) {


    Test test=new Test();
    try{

        test.func("ffff","dddd");
    }catch (RuntimeException o){
        o.printStackTrace();
    }


    }


    public static void main1(String[] args) {

        Array<String> array=new Array<>();

        array.setArray(0,"大明王朝");
        System.out.println(array.getArray(0));

        Array<Integer> array1=new Array<>();
        array1.setArray(0,444);


    }

}
